﻿/** 设置各Emu平台的名字,以及相关快捷键的类,是一个静态类
*/

class MyEmu {

  /* 各个Emu平台的名字,常量
  */
  static WINKAWAKS := "winkawaks.exe"
  static XZONE := "x-zone.exe"
  static NEBULA := "nebula.exe"
  static FBAS := "fbas.exe"

  /* 设置各平台的热键的函数,exeName应该是上面各Emu平台的名字之一
  */
  static setupHotkeys(exeName){

    switch (exeName)
    {
      case this.WINKAWAKS:
      {
        HotIfWinActive("ahk_exe " . exeName)
        Hotkey("del", this._winkawaks_stateSave.bind(this))
        Hotkey("pgdn", this._winkawaks_stateLoad.bind(this))
        Hotkey("home", this._winkawaks_nextState.bind(this))
        Hotkey("pgup", this._winkawaks_previouState.bind(this))
        Hotkey("numpad0", this._winkawaks_pause.bind(this))
        HotIfWinActive()
      }
      case this.NEBULA:
      {
        HotIfWinActive("ahk_exe " . exeName)
        Hotkey("del", this._nebula_stateSave.bind(this))
        Hotkey("pgdn", this._nebula_stateLoad.bind(this))
        Hotkey("numpad0", this._nebula_pause.bind(this))
        HotIfWinActive()
      }
      case this.XZONE:
      {
        HotIfWinActive("ahk_exe " . exeName)
        Hotkey("numpad2", this._xzone_suspend.bind(this))
        Hotkey("space", this._xzoneg_space.bind(this))
        HotIfWinActive()
      }
    }

  }

  /* winkawaks.exe的热键函数
  */
  static _winkawaks_stateSave(key){
    send("{F5 down}{F5 up}")
  }
  static _winkawaks_stateLoad(key){
    send("{F7 down}{F7 up}")
  }
  static _winkawaks_nextState(key){
    send("{F8 down}{F8 up}")
  }
  static _winkawaks_previouState(key){
    send("{F6 down}{F6 up}")
  }
  static _winkawaks_pause(key){
    send("{enter down}{enter up}")
  }

  /* nebula.exe的热键函数
  */
  static _nebula_stateSave(key){
    send("{F10 down}")
    sleep(50)
    send("{F10 up}")
  }
  static _nebula_stateLoad(key){
    send("{F11 down}")
    sleep(50)
    send("{F11 up}")
  }
  static _nebula_pause(key){
    send("{pause down}")
    sleep(50)
    send("{pause up}")
  }

  /* x-zone.exe的热键函数
  */
  static _xzone_suspend(key){ ;热键状态切换
    Suspend()
  }
  static _xzoneg_space(key){ ;空格键作用,替换成p键
    send("{p down}")
    sleep(50)
    send("{p up}")
  }

}